package com.csii.epaySandbox.serviceImpl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.csii.epaySandbox.dao.DeptDao;
import com.csii.epaySandbox.exception.BankException;
import com.csii.epaySandbox.service.BankService;
import com.csii.epaySandbox.util.Utils;
@Service("bankService")
public class BankServiceImpl implements BankService {

	@Resource
	private DeptDao deptDao;

	public List<Map<String, String>> getBankList(String departmentId) {
		if(Utils.isEmpty(departmentId)){
			throw new BankException("机构号为空");
		}
		//查询该机构的联调银行信息
		List bankMsgList = deptDao.findBankOfDept(departmentId);
		List bankList = new ArrayList();
		for(Iterator it = bankMsgList.iterator() ; it.hasNext() ;){
			Map paraMap = (Map) it.next();
			int count = deptDao.findSumOfSuccess(paraMap);//成功案例数
			paraMap.put("count", count);
			bankList.add(paraMap);
		}
		if(Utils.isEmpty(bankList)){
			throw new BankException("该机构下无测试银行");
		}
		return bankList;
	}

}
